package com.wangp.mywrite.coding;

/**
 * @description: 1124. 表现良好的最长时间段
 * @author tooStronger
 * @date 2023/2/14
 */
public class LongestWPI {

    public int longestWPI(int[] hours) {
        int res = 0;

        for (int i = 0; i < hours.length; i++) {
            if (hours[i] <= 8) {
                continue;
            }
            int temp = 1;
            int day = 0;
            for (int j = i + 1; j < hours.length; j++) {
                if (hours[j] > 8) {
                    day++;
                    temp++;
                } else if (day > 0) {
                    day--;
                    temp++;
                } else {
                    break;
                }
            }
            res = Math.max(temp, res);
        }
        return res;
    }

    public static void main(String[] args) {
        System.out.println(new LongestWPI().longestWPI(new int[]{9, 9, 6, 0, 6, 6, 9}));
//        System.out.println(new LongestWPI().longestWPI(new int[]{6,9,6}));
    }
}
